<?php
function echoPlayerDeltasRow(& $delta, $row) {
    global $teams;
    $team = $teams->getTeam($delta->teamId);
    echo getEchoTR(($row +1), "center");
    echo "  <td align=left>" . getEchoValue($team->getRosterLink()) . "</td>\n";
    $name = $delta->name;
    if (strlen($name) == 0) {
        $name = "#" . $delta->rosterNum;
    }
    echo "  <td align=left><a href=\"player_details.php?playerId=$delta->playerId\" title=\"Player Details\" style=\"TEXT-DECORATION: none\">" . getEchoValue($name) . "</a></td>\n";
    echo "  <td align=left>" . getEchoValue($delta->position) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->ma) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->st) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->ag) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->av) . "</td>\n";
    echo "  <td align=left><font size=\"-1\">" . getEchoValue($delta->skills) . "</font></td>\n";
    echo "  <td>" . getEchoValue($delta->completions) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->tds) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->interceptions) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->casualties) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->mvps) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->exps) . "</td>\n";
    echo "  <td>" . getEchoValue($delta->spps) . "</td>\n";
    echo "</tr>\n";
}

$noSeasonChange = true;
$showStats = true;
include_once ("includes/header.php");

// Touchdownss
echo<<< EOQ
            <caption><h1>Player Stats by Game</h1></caption>
            <tr align="center">
              <th>Team</th>
              <th>Name</th>
              <th>Position</th>
              <th>ma</th>
              <th>st</th>
              <th>ag</th>
              <th>av</th>
              <th>Skills</th>
              <th><a href="?sort=2">cp</a></th>
              <th><a href="?sort=3">td</a></th>
              <th><a href="?sort=4">in</a></th>
              <th><a href="?sort=5">cs</a></th>
              <th><a href="?sort=6">mvp</a></th>
              <th><a href="?sort=7">exps</a></th>
              <th><a href="?sort=8">spp</a></th>
            </tr>
EOQ;

$sort = getParam("sort");
if (!isset ($sort)) {
    $sort = 1;
}

$deltas = loadPlayerDeltas($sort);

$i = 0;
foreach ($deltas as $delta) {
    echoPlayerDeltasRow($delta, $i++);
}
include ("includes/footer.php");
?>
